import React from 'react'
import { Router , Route, Switch, Link ,Redirect} from 'react-router-dom';
import Layout from './pages/Layout';
import Login from './pages/Login';
import NotFound from './pages/NotFound';
import history from "@/utils/history";
import { getToken } from './utils/storage';
import  PrivateRoute from "@/components/PrivateRoute";




export default function App() {
  return (
    <Router history={history}>
      <div className='app'>
        {/* <Link to={'/login'}>login</Link>
        <Link to={'/home'}>layout</Link> */}

       <Switch> 
         {/* 一进页面就进layout页面 */}
        <Redirect exact from='/' to={'/home'}></Redirect>
        <Route path={'/login'} component={Login}></Route>
        {/* <PrivateRoute  path={'/home'} component={Layout}></PrivateRoute> */}
        <PrivateRoute  path={'/home'}>
          <Layout></Layout>
        </PrivateRoute>
        <Route component={NotFound}></Route>
       </Switch>
      </div>
    </Router>
  )
}
